/*
 * Copyright 2009 Jesse McLaughlin (nzjess@gmail.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *         http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.travelfusion.xmlclient.ri.xobject.plane;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.travelfusion.xmlclient.ri.xobject.misc.XGetCurrenciesRequest;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * @author Jesse McLaughlin (nzjess@gmail.com)
 */
public class XFlight implements Serializable, IsSerializable {

  private static final long serialVersionUID = 1L;

  private String routingId;

  private String groupId;
  private String groupCurrency;
  private int groupPrice;
  private boolean groupTaxIncluded;

  private String id;
  private String vendor;
  private String[] operators;
  private String currency;
  private int price;
  private boolean taxIncluded;
  private String origin;
  private String destination;
  private Date departureTime;
  private Date arrivalTime;
  private int duration;
  private int numStops;

  private List<XFlightSegment> segments;

  private int usdPrice = -1;

  public String getRoutingId() {
    return routingId;
  }

  public void setRoutingId(String routingId) {
    this.routingId = routingId;
  }

  public String getGroupId() {
    return groupId;
  }

  public void setGroupId(String groupId) {
    this.groupId = groupId;
  }

  public String getGroupCurrency() {
    return groupCurrency;
  }

  public void setGroupCurrency(String groupCurrency) {
    this.groupCurrency = groupCurrency;
  }

  /**
   * This field is stored as the number of hundredths of unit currency.
   */
  public int getGroupPrice() {
    return groupPrice;
  }

  public void setGroupPrice(int groupPrice) {
    this.groupPrice = groupPrice;
  }

  public boolean isGroupTaxIncluded() {
    return groupTaxIncluded;
  }

  public void setGroupTaxIncluded(boolean groupTaxIncluded) {
    this.groupTaxIncluded = groupTaxIncluded;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getVendor() {
    return vendor;
  }

  public void setVendor(String vendor) {
    this.vendor = vendor;
  }

  public String[] getOperators() {
    return operators;
  }

  public void setOperators(String[] operators) {
    this.operators = operators;
  }

  public String getCurrency() {
    return currency;
  }

  public void setCurrency(String currency) {
    this.currency = currency;
  }

  /**
   * This field is stored as the number of hundredths of unit currency.
   */
  public int getPrice() {
    return price;
  }

  public void setPrice(int price) {
    this.price = price;
  }

  public boolean isTaxIncluded() {
    return taxIncluded;
  }

  public void setTaxIncluded(boolean taxIncluded) {
    this.taxIncluded = taxIncluded;
  }

  public String getOrigin() {
    return origin;
  }

  public void setOrigin(String origin) {
    this.origin = origin;
  }

  public String getDestination() {
    return destination;
  }

  public void setDestination(String destination) {
    this.destination = destination;
  }

  public Date getDepartureTime() {
    return departureTime;
  }

  public void setDepartureTime(Date departureTime) {
    this.departureTime = departureTime;
  }

  public Date getArrivalTime() {
    return arrivalTime;
  }

  public void setArrivalTime(Date arrivalTime) {
    this.arrivalTime = arrivalTime;
  }

  public int getDuration() {
    return duration;
  }

  public void setDuration(int duration) {
    this.duration = duration;
  }

  public int getNumStops() {
    return numStops;
  }

  public void setNumStops(int numStops) {
    this.numStops = numStops;
  }

  /**
   * This field may be enabled or disabled (ie. returned as null) depending on the value of the 'segmentsEnabled' flag
   * in the {@link XCheckRoutingRequest} object
   */
  public List<XFlightSegment> getSegments() {
    return segments;
  }

  public void setSegments(List<XFlightSegment> segments) {
    this.segments = segments;
  }

  /**
   * The price of this flight, in USD cents.
   * <p>
   * This field is <strong>NOT</strong> filled in by the API.
   * <p>
   * This field is here for convenience, as many applications will want to calculate its value for a flight. To
   * calculate this value you need to know the appropriate currency conversion rates.
   * <p>
   * TODO document algorithm for calculating this value (unfortunately, it's not as straight-forward as you might guess)
   * 
   * @see XGetCurrenciesRequest
   */
  public int getUsdPrice() {
    return usdPrice;
  }

  public void setUsdPrice(int usdPrice) {
    this.usdPrice = usdPrice;
  }
}
